package su.mvc.util;

import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;
import su.mvc.action.image.ImageAction;

public class ImageBytesResult  implements Result {

    public void execute(ActionInvocation invocation) throws Exception {

        ImageAction action = (ImageAction) invocation.getAction();
        HttpServletResponse response = ServletActionContext.getResponse();

        response.setContentType(action.getContentType());
        response.getOutputStream().write(action.getImageInByte());
        response.getOutputStream().flush();

    }

}
